***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
clear all
log using Log_A2.log, replace

**Calling the data
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures"

***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 


***Figure by country

***Plotting the coefficients 6 largest countries + others
gen country_to_plot=0
replace country_to_plot=1 if countryname=="United Kingdom" | countryname=="France" | countryname=="Germany" | countryname=="Sweden" | countryname=="Italy" | countryname=="Norway" 

***Panel A: First stage

***Creating Interactions of the instrument with each of the countries' indicators
*UK
gen inst_UK=0
replace inst_UK=instrument if countryname=="United Kingdom"
label var inst_UK "United Kingdom"
*France
gen inst_FR=0
replace inst_FR=instrument if countryname=="France"
label var inst_FR "France"
*Germany
gen inst_GE=0
replace inst_GE=instrument if countryname=="Germany"
label var inst_GE "Germany"
*Sweden
gen inst_SE=0
replace inst_SE=instrument if countryname=="Sweden"
label var inst_SE "Sweden"
*Italy
gen inst_IT=0
replace inst_IT=instrument if countryname=="Italy"
label var inst_IT "Italy"
*Norway
gen inst_NO=0
replace inst_NO=instrument if countryname=="Norway"
label var inst_NO "Norway"
**Others
gen inst_Oth=0
replace inst_Oth=instrument if country_to_plot==0
label var inst_Oth "Others"


***First stage
**
set more off
qui xtreg IPO inst_UK inst_FR inst_GE inst_SE inst_IT inst_NO  inst_Oth deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
****
*
coefplot,  keep(inst_UK inst_FR inst_GE inst_SE inst_IT inst_NO  inst_Oth) recast(bar) ciopts(recast(rcap)) citop barwidt(0.5) ///
xline(0) xlabel(, angle(0)) fintensity(20) bcolor(grey) title(Instrument by Country) subtitle(First-stage coefficient) levels(95)

graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\1st stage by country.tif", as(tif) replace

graph export A2A.pdf, replace 

***Panel B: Second stage
***Creating Interactions of the IPO with each of the countries' indicators

***Second stage
gen IPO_UK=0
replace IPO_UK=IPO if countryname=="United Kingdom"
label var IPO_UK "United Kingdom"
*France
gen IPO_FR=0
replace IPO_FR=IPO if countryname=="France"
label var IPO_FR "France"
*Germany
gen IPO_GE=0
replace IPO_GE=IPO if countryname=="Germany"
label var IPO_GE "Germany"
*Sweden
gen IPO_SE=0
replace IPO_SE=IPO if countryname=="Sweden"
label var IPO_SE "Sweden"
*Italy
gen IPO_IT=0
replace IPO_IT=IPO if countryname=="Italy"
label var IPO_IT "Italy"
*Norway
gen IPO_NO=0
replace IPO_NO=IPO if countryname=="Norway"
label var IPO_NO "Norway"
**Others
gen IPO_Oth=0
replace IPO_Oth=IPO if country_to_plot==0
label var IPO_Oth "Others"


set more off
qui xtivreg2 wroa (IPO_UK IPO_FR IPO_GE IPO_SE IPO_IT IPO_NO IPO_Oth=inst_UK inst_FR inst_GE inst_SE inst_IT inst_NO  inst_Oth) ///
 deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* , fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)

coefplot,  keep(IPO_UK IPO_FR IPO_GE IPO_SE IPO_IT IPO_NO IPO_Oth) recast(bar) ciopts(recast(rcap)) citop barwidt(0.5) ///
xline(0) xlabel(, angle(0)) fintensity(20) bcolor(grey) title(IPO effect by Country) subtitle(Second-stage coefficient) levels(95)

graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\2nd stage by country.tif", as(tif) replace

graph export A2B.pdf, replace

***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
log close
graphlog using Log_A2.log, lspacing(1) replace
